package easy;

import java.util.Arrays;
import java.util.HashSet;

/**
 * @author admin
 * 1704. 判断字符串的两半是否相似
 * 用hashset来保存10个元音字母包括大小写，遍历前半段，若含有元音字母，则将count加1，
 * 然后遍历后半段，若含有元音字母，则将count减1，最后count若为0，则相似
 */
public class LeeCode1704 {

    public boolean halvesAreAlike(String s) {

        Character[] temp = new Character[]{'a','e','i','o','u','A','E','I','O','U'};
        HashSet<Character> set = new HashSet<>();
        for (Character character : temp) {
            set.add(character);
        }
        int count = 0;

        for (int i = 0; i < s.length()/2; i++) {
            if (set.contains(s.charAt(i))){
                count++;
                System.out.println(count);
            }
        }
        for (int i = s.length()/2; i < s.length();i++){
            if (set.contains(s.charAt(i))){
                count--;
                System.out.println(count);
            }
        }
        return count==0;
    }

    public static void main(String[] args) {
        System.out.println(new LeeCode1704().halvesAreAlike("book"));
    }
}
